import os

def get_wifi_rssi():
    command = 'sudo iw dev wlan0 scan'
    r = os.popen(command)
    info = r.readlines()
    aaa=[]
    b=[]
    c=[]
    e=[]
    for line in info:
        line = line.strip('\r\n')
        if 'BSS' in line and 'wlan0' in line:
            a=line.split()
            a[1]=a[1].replace('(on','')
            a[1]=a[1].replace(' ','')
            # print(a[1])
            b.append(a[1])
        if 'signal:' in line:
            a=line.split()
            # print(a[1])
            c.append(a[1])
        if 'SSID:' in line:
            a=line.split()
            # print(a[1])
            e.append(a[1])
    for i in range(len(b)):
        aaa.append({'mac':b[i],'rssi':c[i],'ssid':e[i]})
    return aaa